#include<bits/stdc++.h>
using namespace std;
#define il inline
#define fi first
#define se second
#define lhx make_pair
#define eb emplace_back
#define rep(i,l,r) for(int i=(l); i<=(r); ++i)
#define rep_(i,l,r) for(int i=(l); i>=(r); --i)
typedef long long lr;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int N=500500,mod0=1e9+7,mod1=998244353,mod2=1004535809,mod3=2013265921;
constexpr db pi=acos(-1.0),eps=1e-9;
constexpr int inf32=0x3f3f3f3f,Inf32=0xcfcfcfcf;
constexpr lr inf64=0x3f3f3f3f3f3f3f3f,Inf64=0xcfcfcfcfcfcfcfcf;
template<typename T>il T Max(T x,T y)
{
return (x>y)? x:y;
}
template<typename T>il T Min(T x,T y)
{
return (x<y)? x:y;
}
template<typename T>il T gcd(T x,T y)
{
return (!y)? x:gcd(y,x%y);
}
template<typename T>il T Abs(T x)
{
return (x>0)? x:(-x);
}
int n,m,a[N],f[N];
pii g[N];
il int Inv(int x)
{
int y=mod1-2,mul=1;
while(y)
{
if(y&1)
mul=(lr)mul*x%mod1;
x=(lr)x*x%mod1,y>>=1;
}
return mul;
}
il void Solve()
{
cin>>n;
rep(i,1,n)
cin>>a[i],m+=a[i];
rep(i,0,m-1)
{
int p=Inv(((lr)(n-2)*i%mod1+m-(lr)(n-1)*i%mod1*g[i-1].fi%mod1+mod1)%mod1);
g[i].fi=(lr)(m-i)*p%mod1,g[i].se=((lr)(n-1)*i%mod1*g[i-1].se%mod1+(lr)(n-1)*m%mod1)%mod1*p%mod1;
}
rep_(i,m-1,0)
f[i]=((lr)f[i+1]*g[i].fi%mod1+g[i].se)%mod1;
int ans=0;
rep(i,1,n)
ans=(ans+f[a[i]])%mod1;
ans=(ans-(lr)(n-1)*f[0]%mod1+mod1)%mod1;
cout<<(lr)ans*Inv(n)%mod1<<'\n';
}
int main()
{
#ifdef FILEIO
string pre="hack",isuf="in",osuf="out";
freopen((pre+"."+isuf).c_str(),"r",stdin);
freopen((pre+"."+osuf).c_str(),"w",stdout);
#endif
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T=1;
while(T--)
Solve();
return 0;
}
1588. Sum of All Odd Length Subarrays | 1662. Check If Two String Arrays are Equivalent |
1832. Check if the Sentence Is Pangram | 1678. Goal Parser Interpretation |
1389. Create Target Array in the Given Order | 1313. Decompress Run-Length Encoded List |
1281. Subtract the Product and Sum of Digits of an Integer | 1342. Number of Steps to Reduce a Number to Zero |
1528. Shuffle String | 1365. How Many Numbers Are Smaller Than the Current Number |
771. Jewels and Stones | 1512. Number of Good Pairs |
672. Richest Customer Wealth | 1470. Shuffle the Array |
1431. Kids With the Greatest Number of Candies | 1480. Running Sum of 1d Array |
682. Baseball Game | 496. Next Greater Element I |
232. Implement Queue using Stacks | 844. Backspace String Compare |
20. Valid Parentheses | 746. Min Cost Climbing Stairs |
392. Is Subsequence | 70. Climbing Stairs |
53. Maximum Subarray | 1527A. And Then There Were K |
1689. Partitioning Into Minimum Number Of Deci-Binary Numbers | 318. Maximum Product of Word Lengths |
448. Find All Numbers Disappeared in an Array | 1155. Number of Dice Rolls With Target Sum |